Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[16.0][MIG] stock_request_picking_type: Migration to 16.0 #21

Merged
merged 35 commits into from
Jun 13, 2024

Conversation

peluko00
Copy link
Contributor

@peluko00 peluko00 commented Apr 11, 2024

Module migrated to version 16.0

cc https://github.com/APSL 153677

@miquelalzanillas @lbarry-apsl @javierobcn @mpascuall please review

max3903 and others added 30 commits April 11, 2024 15:32
[UPD] README.rst

[UPD] Update stock_request_picking_type.pot

[UPD] README.rst

[UPD] Update stock_request_picking_type.pot
[UPD] Update stock_request_picking_type.pot

[UPD] README.rst

Added translation using Weblate (Chinese (Simplified))

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (28 of 28 strings)

Translation: stock-logistics-warehouse-12.0/stock-logistics-warehouse-12.0-stock_request_picking_type
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_request_picking_type/zh_CN/

Added translation using Weblate (Spanish)

Translated using Weblate (Spanish)

Currently translated at 100.0% (28 of 28 strings)

Translation: stock-logistics-warehouse-12.0/stock-logistics-warehouse-12.0-stock_request_picking_type
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_request_picking_type/es/
[UPD] README.rst

[UPD] Update stock_request_picking_type.pot

[UPD] README.rst

[UPD] Update stock_request_picking_type.pot
[UPD] Update stock_request_picking_type.pot

[UPD] README.rst

Added translation using Weblate (Chinese (Simplified))

Translated using Weblate (Chinese (Simplified))

Currently translated at 100.0% (28 of 28 strings)

Translation: stock-logistics-warehouse-12.0/stock-logistics-warehouse-12.0-stock_request_picking_type
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_request_picking_type/zh_CN/

Added translation using Weblate (Spanish)

Translated using Weblate (Spanish)

Currently translated at 100.0% (28 of 28 strings)

Translation: stock-logistics-warehouse-12.0/stock-logistics-warehouse-12.0-stock_request_picking_type
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_request_picking_type/es/

Added translation using Weblate (Portuguese (Brazil))

Translated using Weblate (Portuguese (Brazil))

Currently translated at 100.0% (28 of 28 strings)

Translation: stock-logistics-warehouse-12.0/stock-logistics-warehouse-12.0-stock_request_picking_type
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-12-0/stock-logistics-warehouse-12-0-stock_request_picking_type/pt_BR/
To appear in OCA shop in the good category.
[UPD] Update stock_request_picking_type.pot

Update translation files

Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: stock-logistics-warehouse-13.0/stock-logistics-warehouse-13.0-stock_request_picking_type
Translate-URL: https://translation.odoo-community.org/projects/stock-logistics-warehouse-13-0/stock-logistics-warehouse-13-0-stock_request_picking_type/
@OCA-git-bot
Copy link
Contributor

There's no issue in this repo with the title 'Migration to version 16.0' and the milestone 16.0, so not possible to add the comment.

}
)
)

def _create_product(self, default_code, name, company_id, **vals):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove those kind of helper methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@@ -74,39 +90,11 @@ def setUpClass(cls):
"stock.no_auto_scheduler", "True"
)

def _create_user(self, name, group_ids, company_ids):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't remove those helper methods.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

@peluko00 peluko00 force-pushed the 16.0-mig-stock_request_picking_type branch from cc31dd5 to eee1a16 Compare May 8, 2024 09:08
@peluko00
Copy link
Contributor Author

peluko00 commented May 8, 2024

Fix it! Can review again please @rousseldenis

Copy link
Member

@lbarry-apsl lbarry-apsl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed

self.env["res.users"]
.with_context({"no_reset_password": True})
cls.env["res.users"]
.with_context(**{"no_reset_password": True})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can avoid such writing by using arguments directly:
.with_context(no_reset_password=True)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix it!

@@ -185,4 +190,4 @@ def test_create(self):
order = self.request_order.with_user(self.stock_request_user).create(order_vals)

# test create()
self.assertEqual(order.picking_type_id, new_pick_type)
self.assertNotEqual(order.picking_type_id, new_pick_type)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this changed ?

Copy link
Contributor Author

@peluko00 peluko00 May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I remove the test because is not impacts in the total coverage at the module and now is not possible to modify the warehouse and location after creation in form.

@peluko00 peluko00 force-pushed the 16.0-mig-stock_request_picking_type branch from eee1a16 to 50b061b Compare May 15, 2024 15:40
Copy link
Contributor

@celm1990 celm1990 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM tested functionally

Copy link
Contributor

@rousseldenis rousseldenis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review

picking_type_id = fields.Many2one(
comodel_name="stock.picking.type",
string="Operation Type",
default=_get_default_picking_type,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This deserves a lambda function instead.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Update: No more default if changed to compute.


@api.model
def _get_default_picking_type(self):
companies = self._context.get("allowed_company_ids", []).copy()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_context is deprecated since a long time: https://github.com/odoo/odoo/blob/16.0/odoo/models.py#L5160

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not why they are using it, we should do it too 🙈

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With self.env.context much better no?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's the one

[
("code", "=", "stock_request_order"),
"|",
("warehouse_id.company_id", "in", companies),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moreover, I think this is not necessary as there is a record rule on picking type. I'm wondering why it is not sufficent to search on...

)

@api.onchange("warehouse_id")
def onchange_warehouse_picking_id(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should now be avoided. You can change the picking_type_id field to a computed/stored/readonly=False field instead and change this to _compute method.

self._origin.write({"picking_type_id": picking_type_id.id})

@api.model
def create(self, vals):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be avoided too referring the remark above.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create() override should be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But the field is required

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compute will do the job as its aim is to get a default value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The compute is not the same as default because on create can't assign a value

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use precompute=True

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix it!

@peluko00 peluko00 force-pushed the 16.0-mig-stock_request_picking_type branch 2 times, most recently from 5ba5b3c to 05cc872 Compare May 16, 2024 09:10
@peluko00
Copy link
Contributor Author

All improvements done @rousseldenis

required=True,
store=True,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should add readonly=False too.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fix it!

@peluko00 peluko00 force-pushed the 16.0-mig-stock_request_picking_type branch from 05cc872 to 6fc78fe Compare May 16, 2024 09:57
@peluko00
Copy link
Contributor Author

It's ready for merge @rousseldenis ?

@peluko00
Copy link
Contributor Author

peluko00 commented Jun 13, 2024

Any update @rousseldenis ? I need that for merge that module

@OCA-git-bot
Copy link
Contributor

This PR has the approved label and has been created more than 5 days ago. It should therefore be ready to merge by a maintainer (or a PSC member if the concerned addon has no declared maintainer). 🤖

@rousseldenis
Copy link
Contributor

/ocabot merge nobump

@OCA-git-bot
Copy link
Contributor

On my way to merge this fine PR!
Prepared branch 16.0-ocabot-merge-pr-21-by-rousseldenis-bump-nobump, awaiting test results.

@OCA-git-bot OCA-git-bot merged commit 192e2f7 into OCA:16.0 Jun 13, 2024
7 checks passed
@OCA-git-bot
Copy link
Contributor

Congratulations, your PR was merged at da59a7d. Thanks a lot for contributing to OCA. ❤️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.